package com.song.test;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author Klys
 * @Date 2023/5/25 16:04
 * @Description
 * @Version 1.0
 */
public class Demo {

    public static void main(String[] args) {

        Demo demo = new Demo();
        demo.getUtilDate();
        demo.getSqlDate();
//        demo.getSimpleDateFormat();
        demo.getTimestamp();

        long l = System.currentTimeMillis();
        System.out.println(l);
    }

    //    获取java.util包下的Date
    public Date getUtilDate() {
        Date date = new Date();
        System.out.println(date);
        return date;
    }

    //    获取java.sql包下的Date
    public Date getSqlDate() {
        java.sql.Date date = new java.sql.Date(8L);
        return date;
    }

    //    获取java.text包下SimpleDateFormat对象
    public void getSimpleDateFormat() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = simpleDateFormat.format(getUtilDate());
        System.out.println(format);
        String format1 = simpleDateFormat.format(getSqlDate());
        System.out.println(format1);
    }

    //    获取Timestamp
    public void getTimestamp() {
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());
        System.out.println(timestamp);
    }


}
